package ${MODEL.packageName};
<#list MODEL.importBao as item >
${item};
</#list>
/**
 * 该代码由程序生成
 */
@Controller
@RequestMapping(value = "user/${MODEL.detailPackge}/${MODEL.beanName}")
public class ${MODEL.beanName}Action  extends BaseAction<${MODEL.beanName}>{
	@Autowired
	${MODEL.beanName}Service ${MODEL.varName}Service;
	
	
	//打开新增或修改页面
	@RequestMapping(value = "/editForm")
	public String editForm(Integer id, HttpServletRequest request) {
		${MODEL.beanName} ${MODEL.varName};
		if (id != null) {
			${MODEL.varName} = ${MODEL.varName}Service.findById(id);
			request.setAttribute("obj", ${MODEL.varName});
		}
		return "user/${MODEL.detailPackge}/${MODEL.beanName}-form";
	}
	@RequestMapping(value = "/addOrModify")
	public  @ResponseBody AjaxResult insertOrUpdata(HttpServletRequest request,
	${MODEL.beanName} ${MODEL.varName}) {
		if(${MODEL.varName}.getId()!=null){
			int i = ${MODEL.varName}Service.modify(${MODEL.varName});
			if (i > 0)
				return new AjaxResult(AjaxResult.STATUS_OK, "修改成功");
			else
				return new AjaxResult(AjaxResult.STATUS_OK, "修改失败");
	} else {
		 int i = ${MODEL.varName}Service.add(${MODEL.varName});
		 if (i > 0)
		 	return new AjaxResult(AjaxResult.STATUS_OK, "增加成功");
		 else
			return new AjaxResult(AjaxResult.STATUS_OK, "增加失败");
	}
		
	}
	
}
